import 'package:ati_package/core/routes/app_routes.dart';
import 'package:ati_package/pages/common/ati_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

import '../../common/widgets/ati_icon_btn.dart';

class NoticeView extends StatefulWidget {
  const NoticeView({super.key});

  @override
  State<NoticeView> createState() => _NoticeViewState();
}

class _NoticeViewState extends State<NoticeView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(
      title: '公告资讯',
      body: ListView.builder(
        itemCount: 5,
        itemBuilder: (context, index) {
          if (index == 4) {
            return Padding(
              padding: const EdgeInsets.all(16.0),
              child: Center(child: Text('没有更多数据了')),
            );
          }

          return announcementItem();
        },
      ),
    );
  }

  Widget announcementItem() {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 16.r, vertical: 5.r),
      child: Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8.r),
        ),
        child: Padding(
          padding: EdgeInsets.all(12.r),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              // 标题
              Text(
                '深圳六旬老汉不配合检疫检查还咬伤',
                style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold),
              ),
              SizedBox(height: 6.r),

              // 副标题
              Text(
                '深圳六旬老汉不配合检疫检查还咬伤警',
                style: TextStyle(fontSize: 14.sp, color: Colors.black87),
              ),
              SizedBox(height: 6.r),

              // 时间 + 按钮
              Container(
                // color: Colors.red,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  // crossAxisAlignment: CrossAxisAlignment.end, // ⬅️ 关键：底部对齐
                  children: [
                    Text(
                      '2025-10-06 10:15:44',
                      style: TextStyle(color: Colors.grey, fontSize: 12.sp),
                    ),
                    AtiIconBtn(
                      titleStr: '查看详情',
                      onPressed: () {
                        Get.toNamed(AtiAppRoutes.noticeDet);
                        print('点击了卡片');
                      },
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
